Skip to content

refactor(filesource): replace repetitive #[cfg()] usages with cfg_if!{}#3832

Closed
rami3l wants to merge 1 commit into
masterfrom
rami3l-patch-1
Closed

refactor(filesource): replace repetitive #[cfg()] usages with cfg_if!{}#3832
rami3l wants to merge 1 commit into
masterfrom
rami3l-patch-1

Conversation

@rami3l

@rami3l rami3l commented May 16, 2024

Copy link
Copy Markdown
Member

It occurred to me right after #3811 that we actually have cfg_if in our imports, so using it more should provide better ergonomics and prevent issues like #3811 happen again (i.e. "I forgot to add #[cfg()] to some constructs but not others").

I plan to adjust #3803 to use cfg_if!{} in rustup-init.rs as well, where we also tend to use quite a lot of conditionally compiled constructs.

@rami3l rami3l requested a review from djc May 16, 2024 02:03
@djc

djc commented May 16, 2024

Copy link
Copy Markdown
Contributor

A simpler way of doing this would be to just move all the test-gated implementations into an inline module which is guarded with #[cfg(feature = "test")] and a single use statement that exports from the inline module. I think I'd prefer that over the cfg_if!{} approach, which is less standard and noisier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants